package com.jian.start;

import com.jian.socks5.common.Constants;
import com.jian.socks5.tcp.handler.ServerChannelInitializer;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/***
 * @author LiJian
 */
public class App {

    public static void main(String[] args) {
        ServerBootstrap serverBootstrap = new ServerBootstrap();
        serverBootstrap.group(Constants.bossEventLoopGroup, Constants.workEventLoopGroup);
        serverBootstrap.option(ChannelOption.SO_BACKLOG, 800);

        // 设置读缓冲区为2M
        serverBootstrap.childOption(ChannelOption.SO_RCVBUF, 2048 * 1024);
        // 设置写缓冲区为1M
        serverBootstrap.childOption(ChannelOption.SO_SNDBUF, 1024 * 1024);

        serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
        serverBootstrap.childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3001);
        serverBootstrap.channel(NioServerSocketChannel.class);
        serverBootstrap.childHandler(ServerChannelInitializer.getServerChannelInitializerInstan(Constants.defaultEventLoopGroup));
        serverBootstrap.bind(9999).syncUninterruptibly();

    }

}















